﻿import QtQuick 2.0

import QtQuick.Controls 1.2



Rectangle{
    width: 320;
    height:240;
    color:"gray";

    Component{
        id:colorComponent;
        Rectangle{
            id:colorPicker;
            width:50;
            height: 30;
            signal colorPicked(color clr);
            MouseArea{
                anchors.fill: parent;
                onClicked: {
                    colorPicker.colorPicked(colorPicker.color);
                }
            }
        }
    }

    Text{
        id:textShow;
        text:"hello loader focus key";
        anchors.horizontalCenter: parent.horizontalCenter;
        anchors.top: parent.top;
        anchors.topMargin: 4;
        font.pixelSize: 36;
        color:"red";
    }

    Loader{
        id: greenLoader;
        anchors.horizontalCenter: parent.horizontalAlignment;
        anchors.bottom: parent.bottom;
        sourceComponent: colorComponent;
        onLoaded: {
            item.color = "green";
        }
    }


    Loader{
        id: yelloLoader;
        anchors.verticalCenter: greenLoader.verticalCenter;
        anchors.left: greenLoader.right;
        sourceComponent: colorComponent;
        onLoaded: {
            item.color = "yellow";
        }
    }

    Connections{
        target: greenLoader.item;
        onColorPicked:{
            textShow.color = clr;
        }
    }

    Connections{
        target: yelloLoader.item;
        onColorPicked:{
            textShow.color = clr;
        }
    }


}
